﻿using System;
using System.Windows;
using Flexible.Implementions.Bases;
using Flexible.Interfaces;
using System.Windows.Controls;

namespace Flexible.Wpf
{
    public class WindowPlugin : PluginBase, IApplication
    {
        public WindowPlugin()
        {
        }

        Window window;
        StackPanel mainRegion;
        Application application;

        public Window Window
        {
            get { return window; }
        }

        public Application Application
        {
            get { return application; }
        }

        public StackPanel MainRegion
        {
            get { return mainRegion; }
        }

        public override void Enable(IPluginActivateContext context)
        {
            mainRegion = new StackPanel();
            window = new Window();
            window.Content = mainRegion;
            application = new Application();
        }

        public override void Disable(IPluginActivateContext context)
        {
            application.Shutdown();
        }

        #region Info
        public override string Name
        {
            get { return "Main Window"; }
        }

        public override string Description
        {
            get { return "Main window of the application."; }
        }

        public override string Author
        {
            get { return "deerchao"; }
        }

        public override DateTime ReleaseTime
        {
            get { return new DateTime(2008, 4, 9); }
        }

        public override string Id
        {
            get { return "Flexible.Wpf.Window"; }
        }

        public override Version Version
        {
            get { return new Version(1, 0, 0, 0); }
        }

        public override Version CompatibleVersion
        {
            get { return new Version(1, 0, 0, 0); }
        }
        #endregion

        #region IApplication Members

        public bool Run()
        {
            application.Run(window);
            return true;
        }

        #endregion
    }
}
